﻿using Microsoft.AspNetCore.Http;
using SportsPlatform.Helpers;
using SportsPlatform.Model.PermissionManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SportsPlatform.Global
{
    /// <summary>
    /// Session上下文
    /// </summary>
    public class UldAdminSessionContext
    {
        /// <summary>
        /// 当前用户
        /// </summary>
        /// <param name="context">HttpContext</param>
        /// <returns>用户信息</returns>
        public static UserInfo GetCurrentUserInfo(IHttpContextAccessor context)
        {
            var token = context.HttpContext.GetToken();

            var user = UldRedisContext.Get<UserInfo>(token);

            return user;
        }
    }
}
